home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from util import threaded, UrlQuery
- from urllib import FancyURLopener
- from hashlib import sha256
- from logging import getLogger
- log = getLogger('digsby.web')
- ACCOUNT_URL = 'https://accounts.digsby.com/login.php'
-
- class DigsbyHttpError(Exception):
- pass
-
-
- class DigsbyHttp(object):
-
- def __init__(self, username, password, url = ACCOUNT_URL):
- self.username = username
- self.password = sha256(password).hexdigest()
- self.url = url
-
-
- def __repr__(self):
- return '<%s to %s>' % (self.__class__.__name__, self.url)
-
-
- def _urlopen(self, **params):
- resp = digsby_webget_no_thread(self.url, user = self.username, key = self.password, **params)
- if resp == 'ERR':
- raise DigsbyHttpError('server indicated error: %r' % resp)
-
- return resp
-
- GET = _urlopen
-
-
- def digsby_acct_http(username, password, **params):
- return digsby_webget_no_thread(ACCOUNT_URL, user = username, key = sha256(password).hexdigest(), **params)
-
-
- def digsby_webget(url, **params):
- return digsby_webget_no_thread(url, **params)
-
- digsby_webget = threaded(digsby_webget)
-
- def digsby_webget_no_thread(url, **params):
- http_opener = FancyURLopener()
- http_opener.addheaders = [
- ('Cache-Control', 'no-cache'),
- ('User-Agent', 'Digsby')]
- log.info('GETting url %s', url)
- url = UrlQuery(url, **params)
- log.info_s('full query is %s', url)
- response = http_opener.open(url)
- res = response.read()
- response.close()
- log.info('response: %r', res)
- return res
-
-
- class DigsbyFancyURLopener(FancyURLopener):
-
- def prompt_user_passwd(self, host, realm):
- return ('', '')
-
-
-